﻿using Basic.FormDAL;
using Basic.FormModel.DB;
using Basic.FormRemoteModel;
using WeDonekRpc.Helper;

namespace Basic.FormCollect.lmpl
{
    internal class QueryControlCollect : IQueryControlCollect
    {
        private readonly IQueryControlDAL _BasicDAL;

        public QueryControlCollect ( IQueryControlDAL basicDAL )
        {
            this._BasicDAL = basicDAL;
        }

        public DBQueryControl[] GetEnables ( LayoutLocation location )
        {
            return this._BasicDAL.Gets<DBQueryControl>(a => a.Location == location && a.Status == QueryControlStatus.启用);
        }

        public Dictionary<long, string> GetNames ( long[] ids )
        {
            if ( ids.IsNull() )
            {
                return null;
            }
            return this._BasicDAL.Gets(ids, a => new
            {
                a.Id,
                a.Name
            }).ToDictionary(a => a.Id, a => a.Name);
        }
    }
}
